<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - /usr/local/include/boost/progress.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../../../index.html">directory</a> - <a href="index.html">usr/local/include/boost</a> - progress.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">22</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">0.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">0</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : //  boost progress.hpp header file  ------------------------------------------//
<span class="lineNum">       2 </span>                : 
<span class="lineNum">       3 </span>                : //  Copyright Beman Dawes 1994-99.  Distributed under the Boost
<span class="lineNum">       4 </span>                : //  Software License, Version 1.0. (See accompanying file
<span class="lineNum">       5 </span>                : //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       6 </span>                : 
<span class="lineNum">       7 </span>                : //  See http://www.boost.org/libs/timer for documentation.
<span class="lineNum">       8 </span>                : 
<span class="lineNum">       9 </span>                : //  Revision History
<span class="lineNum">      10 </span>                : //   1 Dec 01  Add leading progress display strings (suggested by Toon Knapen)
<span class="lineNum">      11 </span>                : //  20 May 01  Introduce several static_casts&lt;&gt; to eliminate warning messages
<span class="lineNum">      12 </span>                : //             (Fixed by Beman, reported by Herve Bronnimann)
<span class="lineNum">      13 </span>                : //  12 Jan 01  Change to inline implementation to allow use without library
<span class="lineNum">      14 </span>                : //             builds. See docs for more rationale. (Beman Dawes) 
<span class="lineNum">      15 </span>                : //  22 Jul 99  Name changed to .hpp
<span class="lineNum">      16 </span>                : //  16 Jul 99  Second beta
<span class="lineNum">      17 </span>                : //   6 Jul 99  Initial boost version
<span class="lineNum">      18 </span>                : 
<span class="lineNum">      19 </span>                : #ifndef BOOST_PROGRESS_HPP
<span class="lineNum">      20 </span>                : #define BOOST_PROGRESS_HPP
<span class="lineNum">      21 </span>                : 
<span class="lineNum">      22 </span>                : #include &lt;boost/timer.hpp&gt;
<span class="lineNum">      23 </span>                : #include &lt;boost/utility.hpp&gt;  // for noncopyable
<span class="lineNum">      24 </span>                : #include &lt;boost/cstdint.hpp&gt;  // for uintmax_t
<span class="lineNum">      25 </span>                : #include &lt;iostream&gt;           // for ostream, cout, etc
<span class="lineNum">      26 </span>                : #include &lt;string&gt;             // for string
<span class="lineNum">      27 </span>                : 
<span class="lineNum">      28 </span>                : namespace boost {
<span class="lineNum">      29 </span>                : 
<span class="lineNum">      30 </span>                : //  progress_timer  ----------------------------------------------------------//
<span class="lineNum">      31 </span>                : 
<span class="lineNum">      32 </span>                : //  A progress_timer behaves like a timer except that the destructor displays
<span class="lineNum">      33 </span>                : //  an elapsed time message at an appropriate place in an appropriate form.
<span class="lineNum">      34 </span>                : 
<span class="lineNum">      35 </span>                : class progress_timer : public timer, private noncopyable
<span class="lineNum">      36 </span>                : {
<span class="lineNum">      37 </span>                :   
<span class="lineNum">      38 </span>                :  public:
<span class="lineNum">      39 </span>                :   explicit progress_timer( std::ostream &amp; os = std::cout )
<span class="lineNum">      40 </span>                :      // os is hint; implementation may ignore, particularly in embedded systems
<span class="lineNum">      41 </span>                :      : m_os(os) {}
<span class="lineNum">      42 </span>                :   ~progress_timer()
<span class="lineNum">      43 </span>                :   {
<span class="lineNum">      44 </span>                :   //  A) Throwing an exception from a destructor is a Bad Thing.
<span class="lineNum">      45 </span>                :   //  B) The progress_timer destructor does output which may throw.
<span class="lineNum">      46 </span>                :   //  C) A progress_timer is usually not critical to the application.
<span class="lineNum">      47 </span>                :   //  Therefore, wrap the I/O in a try block, catch and ignore all exceptions.
<span class="lineNum">      48 </span>                :     try
<span class="lineNum">      49 </span>                :     {
<span class="lineNum">      50 </span>                :       // use istream instead of ios_base to workaround GNU problem (Greg Chicares)
<span class="lineNum">      51 </span>                :       std::istream::fmtflags old_flags = m_os.setf( std::istream::fixed,
<span class="lineNum">      52 </span>                :                                                    std::istream::floatfield );
<span class="lineNum">      53 </span>                :       std::streamsize old_prec = m_os.precision( 2 );
<span class="lineNum">      54 </span>                :       m_os &lt;&lt; elapsed() &lt;&lt; &quot; s\n&quot; // &quot;s&quot; is System International d'Unites std
<span class="lineNum">      55 </span>                :                         &lt;&lt; std::endl;
<span class="lineNum">      56 </span>                :       m_os.flags( old_flags );
<span class="lineNum">      57 </span>                :       m_os.precision( old_prec );
<span class="lineNum">      58 </span>                :     }
<span class="lineNum">      59 </span>                : 
<span class="lineNum">      60 </span>                :     catch (...) {} // eat any exceptions
<span class="lineNum">      61 </span>                :   } // ~progress_timer
<span class="lineNum">      62 </span>                : 
<span class="lineNum">      63 </span>                :  private:
<span class="lineNum">      64 </span>                :   std::ostream &amp; m_os;
<span class="lineNum">      65 </span>                : };
<span class="lineNum">      66 </span>                : 
<span class="lineNum">      67 </span>                : 
<span class="lineNum">      68 </span>                : //  progress_display  --------------------------------------------------------//
<span class="lineNum">      69 </span>                : 
<span class="lineNum">      70 </span>                : //  progress_display displays an appropriate indication of 
<span class="lineNum">      71 </span>                : //  progress at an appropriate place in an appropriate form.
<span class="lineNum">      72 </span>                : 
<span class="lineNum">      73 </span>                : // NOTE: (Jan 12, 2001) Tried to change unsigned long to boost::uintmax_t, but
<span class="lineNum">      74 </span>                : // found some compilers couldn't handle the required conversion to double.
<span class="lineNum">      75 </span>                : // Reverted to unsigned long until the compilers catch up. 
<span class="lineNum">      76 </span>                : 
<span class="lineNum">      77 </span>                : class progress_display : private noncopyable
<span class="lineNum">      78 </span><span class="lineNoCov">              0 : {</span>
<span class="lineNum">      79 </span>                :  public:
<span class="lineNum">      80 </span><span class="lineNoCov">              0 :   explicit progress_display( unsigned long expected_count,</span>
<span class="lineNum">      81 </span>                :                              std::ostream &amp; os = std::cout,
<span class="lineNum">      82 </span>                :                              const std::string &amp; s1 = &quot;\n&quot;, //leading strings
<span class="lineNum">      83 </span>                :                              const std::string &amp; s2 = &quot;&quot;,
<span class="lineNum">      84 </span>                :                              const std::string &amp; s3 = &quot;&quot; )
<span class="lineNum">      85 </span>                :    // os is hint; implementation may ignore, particularly in embedded systems
<span class="lineNum">      86 </span><span class="lineNoCov">              0 :    : m_os(os), m_s1(s1), m_s2(s2), m_s3(s3) { restart(expected_count); }</span>
<span class="lineNum">      87 </span>                : 
<span class="lineNum">      88 </span><span class="lineNoCov">              0 :   void           restart( unsigned long expected_count )</span>
<span class="lineNum">      89 </span>                :   //  Effects: display appropriate scale
<span class="lineNum">      90 </span>                :   //  Postconditions: count()==0, expected_count()==expected_count
<span class="lineNum">      91 </span>                :   {
<span class="lineNum">      92 </span><span class="lineNoCov">              0 :     _count = _next_tic_count = _tic = 0;</span>
<span class="lineNum">      93 </span><span class="lineNoCov">              0 :     _expected_count = expected_count;</span>
<span class="lineNum">      94 </span>                : 
<span class="lineNum">      95 </span>                :     m_os &lt;&lt; m_s1 &lt;&lt; &quot;0%   10   20   30   40   50   60   70   80   90   100%\n&quot;
<span class="lineNum">      96 </span>                :          &lt;&lt; m_s2 &lt;&lt; &quot;|----|----|----|----|----|----|----|----|----|----|&quot;
<span class="lineNum">      97 </span>                :          &lt;&lt; std::endl  // endl implies flush, which ensures display
<span class="lineNum">      98 </span><span class="lineNoCov">              0 :          &lt;&lt; m_s3;</span>
<span class="lineNum">      99 </span><span class="lineNoCov">              0 :     if ( !_expected_count ) _expected_count = 1;  // prevent divide by zero</span>
<span class="lineNum">     100 </span><span class="lineNoCov">              0 :   } // restart</span>
<span class="lineNum">     101 </span>                : 
<span class="lineNum">     102 </span><span class="lineNoCov">              0 :   unsigned long  operator+=( unsigned long increment )</span>
<span class="lineNum">     103 </span>                :   //  Effects: Display appropriate progress tic if needed.
<span class="lineNum">     104 </span>                :   //  Postconditions: count()== original count() + increment
<span class="lineNum">     105 </span>                :   //  Returns: count().
<span class="lineNum">     106 </span>                :   {
<span class="lineNum">     107 </span><span class="lineNoCov">              0 :     if ( (_count += increment) &gt;= _next_tic_count ) { display_tic(); }</span>
<span class="lineNum">     108 </span><span class="lineNoCov">              0 :     return _count;</span>
<span class="lineNum">     109 </span>                :   }
<span class="lineNum">     110 </span>                : 
<span class="lineNum">     111 </span><span class="lineNoCov">              0 :   unsigned long  operator++()           { return operator+=( 1 ); }</span>
<span class="lineNum">     112 </span><span class="lineNoCov">              0 :   unsigned long  count() const          { return _count; }</span>
<span class="lineNum">     113 </span>                :   unsigned long  expected_count() const { return _expected_count; }
<span class="lineNum">     114 </span>                : 
<span class="lineNum">     115 </span>                :   private:
<span class="lineNum">     116 </span>                :   std::ostream &amp;     m_os;  // may not be present in all imps
<span class="lineNum">     117 </span>                :   const std::string  m_s1;  // string is more general, safer than 
<span class="lineNum">     118 </span>                :   const std::string  m_s2;  //  const char *, and efficiency or size are
<span class="lineNum">     119 </span>                :   const std::string  m_s3;  //  not issues
<span class="lineNum">     120 </span>                : 
<span class="lineNum">     121 </span>                :   unsigned long _count, _expected_count, _next_tic_count;
<span class="lineNum">     122 </span>                :   unsigned int  _tic;
<span class="lineNum">     123 </span><span class="lineNoCov">              0 :   void display_tic()</span>
<span class="lineNum">     124 </span>                :   {
<span class="lineNum">     125 </span>                :     // use of floating point ensures that both large and small counts
<span class="lineNum">     126 </span>                :     // work correctly.  static_cast&lt;&gt;() is also used several places
<span class="lineNum">     127 </span>                :     // to suppress spurious compiler warnings. 
<span class="lineNum">     128 </span>                :     unsigned int tics_needed =
<span class="lineNum">     129 </span>                :       static_cast&lt;unsigned int&gt;(
<span class="lineNum">     130 </span><span class="lineNoCov">              0 :         (static_cast&lt;double&gt;(_count)/_expected_count)*50.0 );</span>
<span class="lineNum">     131 </span><span class="lineNoCov">              0 :     do { m_os &lt;&lt; '*' &lt;&lt; std::flush; } while ( ++_tic &lt; tics_needed );</span>
<span class="lineNum">     132 </span>                :     _next_tic_count = 
<span class="lineNum">     133 </span><span class="lineNoCov">              0 :       static_cast&lt;unsigned long&gt;((_tic/50.0)*_expected_count);</span>
<span class="lineNum">     134 </span><span class="lineNoCov">              0 :     if ( _count == _expected_count ) {</span>
<span class="lineNum">     135 </span><span class="lineNoCov">              0 :       if ( _tic &lt; 51 ) m_os &lt;&lt; '*';</span>
<span class="lineNum">     136 </span><span class="lineNoCov">              0 :       m_os &lt;&lt; std::endl;</span>
<span class="lineNum">     137 </span>                :       }
<span class="lineNum">     138 </span><span class="lineNoCov">              0 :   } // display_tic</span>
<span class="lineNum">     139 </span>                : };
<span class="lineNum">     140 </span>                : 
<span class="lineNum">     141 </span>                : } // namespace boost
<span class="lineNum">     142 </span>                : 
<span class="lineNum">     143 </span>                : #endif  // BOOST_PROGRESS_HPP
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
